package com.runfast.paotui.service.impl;

import com.runfast.common.service.BaseService;
import com.runfast.paotui.dao.model.PaotuiCost;
import com.runfast.paotui.dao.model.PaotuiCostExample;
import com.runfast.paotui.service.PaotuiCostService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PaotuiCostServiceImpl extends BaseService<PaotuiCost, Integer, PaotuiCostExample> implements PaotuiCostService {

    public void saveFor(PaotuiCost t){

        PaotuiCostExample example=new PaotuiCostExample();
        example.createCriteria().andAgentidEqualTo(t.getAgentid());
        List<PaotuiCost> olds=mapper.selectByExample(example);
            if(olds.size()>0){
                 t.setIsdefault(0);
            }else{
                t.setIsdefault(1);
            }
        mapper.insertSelective(t);
    }
}